<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let input = `5
1 0 100
2 4 200
3 4 300
4 0 200
5 1 200`
        let spl = input.split('\n')
        let N = parseInt(spl.shift())

        let BoosIndex = null
        let moneyArr = new Array(N + 1).fill(0)
        let list = spl.map(v => v.trim().split(' ').map(j => parseInt(j.trim())))
        let obj={}
        let visited=new Set()
        list.forEach(v => {
            moneyArr[v[0]] = v[2]
            if(visited.has(v[1])){
                obj[v[1]].push(v[0])
            }else{
                visited.add(v[1])
                obj[v[1]]=[v[0]]
            }
        })

        BoosIndex=moneyArr.findIndex(v=>v===0)

        console.log(obj);

        function dps(arr){

            while(arr.length){
                let T=arr.shift()
                if(visited.has(T)){
                    let Arr=[...obj[T]]
                    dps(Arr)
                }
                if(T-1>=0){
                    let index=null
                    for(let i=0;i<list.length;i++){
                      if(list[i][0]===T) {
                        index=i
                      } 

                    }
                    moneyArr[list[index][1]]+=Math.floor(moneyArr[T]/100) *15
                    console.log('子：',T,'父：',list[T-1][1]);
                    
                }
                
            }
      
        }
             
        console.log(moneyArr);
        dps([BoosIndex])       
        console.log(moneyArr);
        console.log(...list);
        console.log(obj);

    </script>
</body>

</html>